package com.esun.rabbit2.communicaters.hemai;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;

import javax.xml.parsers.ParserConfigurationException;

import org.apache.http.client.ClientProtocolException;
import org.xml.sax.SAXException;

import com.esun.config.BussinessCode;
import com.esun.config.Key;
import com.esun.model.UserInfo;
import com.esun.network.ServerCommunicater;

/**
 * @ClassName: HeMaiExpectCommunicater
 * @Description: (获取彩种期号接口)
 * @author: Billy Qigs@500wan.com
 * @date: 2011-12-2 上午11:46:25
 * 
 */
public class HeMaiExpectCommunicater extends ServerCommunicater {

	private String serverMsg = "";
	private String strExpect = "";

	public boolean isGetExpectSucceed(String lotid) throws ClientProtocolException, IOException, ParserConfigurationException, SAXException {

		boolean isSucceed = false;

		ArrayList<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>();
		list.add(mapItem(BussinessCode.PASER_MID, BussinessCode.MID_GET_HEMAI_LIST_EXPECT));
		list.add(mapItem(BussinessCode.PASER_CK, UserInfo.getUserInfo().getUserSession()));
		list.add(mapItem(Key.KEY_LOTID, lotid));
		// 写入服务器返回信息
		super.getServerResponse(list, true);
		setServerMessage(super.getServerMsg());
		if (super.getState() == 100) {
			isSucceed = true;
			setExpect(super.getListResult().get(0).get(Key.KEY_EXPECT));
		} else {
			isSucceed = false;
		}
		return isSucceed;

	}

	private void setServerMessage(String str) {
		serverMsg = str;
	}

	public String getServerMsg() {
		return serverMsg;
	}

	private void setExpect(String str) {
		strExpect = str;
	}

	public String getExpect() {
		return strExpect;
	}

	private HashMap<String, String> mapItem(String name, String value) {
		HashMap<String, String> map = new HashMap<String, String>();
		map.put(name, value);
		return map;
	}

}
